package com.example.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.example.pojo.auditProblemListPojo;
import com.example.pojo.fixtureTechConditionPojo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDateTime;
import java.util.List;

/**
 * ClassName:auditProblemListMapp
 * Package:com.example.mapper
 * Description:
 *
 * @Author：牧星苑
 * @Create 2025/9/20 14:05
 * @Version 1.0
 */
@Mapper
public interface auditProblemListMapp {
    //插入一行审核问题
    @DS("newMscLowCodeFormal")
    @Insert("insert into ddm_audit_problem_list (" +
            "id, create_time, update_time," +
            "creator, process_status, sys_update_user," +
            "sys_audit_user, sys_audit_time, sys_deleted," +
            "audit_source, audit_date, auditor," +
            "process, problem_type, problem_classification," +
            "file_name, clause_number, problem_photo," +
            "problem_description, reason, corrective_action, " +
            "preventive_action, correction_completion_time, prevention_completion_time, " +
            "evidence_upload, department, correction_responsible_person, " +
            "prevention_responsible_person, audit_person, approver, " +
            "message, completion_mark, incentive_explanation, " +
            "effect_confirmation, confirmer, confirmation_time, " +
            "problem_close, measure_maker)" +
            "values " +
            "(#{id}, #{create_time}, #{update_time}," +
            "#{creator}, #{process_status}, #{sys_update_user}," +
            "#{sys_audit_user}, #{sys_audit_time}, #{sys_deleted}," +
            "#{audit_source}, #{audit_date}, #{auditor}," +
            "#{process}, #{problem_type}, #{problem_classification}," +
            "#{file_name}, #{clause_number}, #{problem_photo}," +
            "#{problem_description}, #{reason}, #{corrective_action}," +
            "#{preventive_action}, #{correction_completion_time}, #{prevention_completion_time}, " +
            "#{evidence_upload}, #{department}, #{correction_responsible_person}," +
            "#{prevention_responsible_person}, #{audit_person}, #{approver}," +
            "#{message}, #{completion_mark}, #{incentive_explanation}," +
            "#{effect_confirmation}, #{confirmer}, #{confirmation_time}, " +
            "#{problem_close}, #{measure_maker})")
    void insertOne(auditProblemListPojo pojo);

    //修改一行审核问题
    @DS("newMscLowCodeFormal")
    @Update("update ddm_audit_problem_list set " +
            "create_time=#{create_time}, " +
            "update_time=#{update_time}, " +
            "creator=#{creator}, " +  // 这里补上逗号
            "process_status=#{process_status}, " +  // 这里补上逗号
            "sys_update_user=#{sys_update_user}, " +
            "sys_audit_user=#{sys_audit_user}, " +
            "sys_audit_time=#{sys_audit_time}, " +
            "sys_deleted=#{sys_deleted}, " +
            "audit_source=#{audit_source}, " +
            "audit_date=#{audit_date}, " +
            "auditor=#{auditor}, " +
            "process=#{process}, " +
            "problem_type=#{problem_type}, " +
            "problem_classification=#{problem_classification}, " +
            "file_name=#{file_name}, " +
            "clause_number=#{clause_number}, " +
            "problem_photo=#{problem_photo}, " +
            "problem_description=#{problem_description}, " +
            "reason=#{reason}, " +
            "corrective_action=#{corrective_action}, " +
            "preventive_action=#{preventive_action}, " +
            "correction_completion_time=#{correction_completion_time}, " +
            "prevention_completion_time=#{prevention_completion_time}, " +
            "evidence_upload=#{evidence_upload}, " +
            "department=#{department}, " +
            "measure_maker=#{measure_maker}, " +
            "correction_responsible_person=#{correction_responsible_person}, " +
            "prevention_responsible_person=#{prevention_responsible_person}, " +
            "audit_person=#{audit_person}, " +
            "approver=#{approver}, " +
            "message=#{message}, " +
            "completion_mark=#{completion_mark}, " +
            "incentive_explanation=#{incentive_explanation}, " +
            "effect_confirmation=#{effect_confirmation}, " +
            "confirmer=#{confirmer}, " +
            "confirmation_time=#{confirmation_time}, " +
            "problem_close=#{problem_close} " +
            "where id=#{id} ")
    void editOneById(auditProblemListPojo pojo);

    //分页查询审核问题
    @DS("newMscLowCodeFormal")
    @Select("select * from ddm_audit_problem_list where sys_deleted=0 " +
            "order by audit_date DESC " +
            "limit #{startRow}, #{size}")
    List<auditProblemListPojo> queryByPage(Integer startRow, Integer size);

    //查询所有审核问题条数
    @DS("newMscLowCodeFormal")
    @Select("SELECT COUNT(*) FROM ddm_audit_problem_list where sys_deleted=0")
    Integer queryQuantity();

    //根据id修改一个字段
    @DS("newMscLowCodeFormal")
    @Update("update ddm_audit_problem_list set " +
            "${fieldName}=#{fieldValue}, update_time=#{updateTime} " +
            "where id=#{id}")
    void editOneField(String id, String fieldName, String fieldValue, LocalDateTime updateTime);
}
